class Solution {
    public int[] xorQueries(int[] arr, int[][] queries) {
        //前缀和
        int n = queries.length;
        int m = queries[0].length;
        int[] ans = new int[n];
        dfs(arr,ans);
        int[] an = new int[n];
        for(int i=0;i<n;++i){
            int j=queries[i][1];
            if(queries[i][0]==0){
                an[i] = ans[i];
            }
            else{
                an[i] = ans[i-1] ^ ans[j];
            }
        }
        return an;
    }
    public void dfs(int[] arr,int[] ans){
        ans[0] = arr[0];
        for(int i=1;i<ans.length;++i){
            ans[i] = ans[i-1] ^ arr[i];
            System.out.println(ans[i]);
        }
    }
    public static void main(String[] args) {
        int[] arr = new int[]{1,3,4,8};
        int[][] queries = {{0,1},{1,2},{0,3},{3,3}};
        Solution ad = new Solution();
        ad.xorQueries(arr,queries);
        
    }

}